﻿<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output media-type="text/plain" method="text" indent="yes" encoding="utf-8" />
  <xsl:template match="/">
    <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">]]></xsl:text>
    <html>
      <head>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta charset="utf-8">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">]]></xsl:text>

        <title>Assembly Difference</title>

        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="description" content="">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="viewport" content="width=device-width">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<META name="Author" content="]]></xsl:text>
        <xsl:value-of select="@ProductName" /> version <xsl:value-of select="@ProductVersion" />
        <xsl:text disable-output-escaping="yes"><![CDATA[">]]></xsl:text>

        <style type="text/css">
          <xsl:comment>Styles here </xsl:comment>
        </style>

      </head>
      <body>
        <xsl:apply-templates select="AssemblyDifference" />

      </body>
    </html>

  </xsl:template>

  <xsl:template match="AssemblyDifference">
    <div id="header">
        <h1>
          <xsl:value-of select="@Name" />
        </h1>

      <xsl:call-template name="navigation" />
    </div>

    <div id="summary">
        <h2>
          <xsl:value-of select="@Name" />
        </h2>
      <table  summary="Summary of changes between versions of this assembly">
        <caption>Summary of changes</caption>
        <tbody>
          <tr>
            <td>% Churn</td>
            <td>
              <xsl:value-of select="@PercentChurn" />
            </td>
          </tr>
          <tr>
            <td>From</td>
            <td>
              <xsl:value-of select="@From" />
            </td>
          </tr>
          <tr>
            <td>To</td>
            <td>
              <xsl:value-of select="@To" />
            </td>
          </tr>
          <tr>
            <td>
              <a href="#removed">Removed</a>
            </td>
            <td>
              <xsl:value-of select="count(RemovedTypes/*)"/>
            </td>
          </tr>
          <tr>
            <td>
              <a href="#obsolete">Obsolete</a>
            </td>
            <td>
              <xsl:value-of select="count(ObsoleteTypes/*)"/>
            </td>
          </tr>
          <tr>
            <td>
              <a href="#changed">Changed</a>
            </td>
            <td>
              <xsl:value-of select="count(ChangedTypes/*)"/>
            </td>
          </tr>
          <tr>
            <td>
              <a href="#added">Added</a>
            </td>
            <td>
              <xsl:value-of select="count(AddedTypes/*)"/>
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <xsl:apply-templates select="RemovedTypes"/>

    <xsl:apply-templates select="ObsoleteTypes"/>

    <xsl:apply-templates select="ChangedTypes"/>

    <xsl:apply-templates select="AddedTypes"/>

    <div id="footer">
      <xsl:call-template name="navigation" />
    </div>

  </xsl:template>

  <xsl:template match="ChangedTypes">

    <xsl:call-template name="write_table">
      <xsl:with-param name="title" select="'Changed Types'" />
      <xsl:with-param name="caption" select="'Types that have changed since the earlier version of this assembly'" />
      <xsl:with-param name="linkid" select="'changed'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="ObsoleteTypes">

    <xsl:call-template name="write_table">
      <xsl:with-param name="title" select="'Obsolete Types'" />
      <xsl:with-param name="caption" select="'Types marked as obsolete since the earlier version of this assembly'" />
      <xsl:with-param name="linkid" select="'obsolete'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="RemovedTypes">

    <xsl:call-template name="write_table">
      <xsl:with-param name="title" select="'Removed Types'" />
      <xsl:with-param name="caption" select="'Types removed from the later version of this assembly'" />
      <xsl:with-param name="linkid" select="'removed'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template match="AddedTypes">

    <xsl:call-template name="write_table">
      <xsl:with-param name="title" select="'Added Types'" />
      <xsl:with-param name="caption" select="'Types added since the earlier version of this assembly'" />
      <xsl:with-param name="linkid" select="'added'" />
    </xsl:call-template>

  </xsl:template>

  <xsl:template name="write_table" >
    <xsl:param name="title" />
    <xsl:param name="caption" />
    <xsl:param name="linkid" />

    <div>
        <h2>
          <xsl:attribute name="id">
            <xsl:value-of select="$linkid"/>
          </xsl:attribute>
          <xsl:value-of select="$title" />
        </h2>
      <table>
        <xsl:attribute name="summary">
          <xsl:value-of select="$caption" />
        </xsl:attribute>
        <caption>
          <xsl:value-of select="$caption" />
        </caption>
        <tbody>
          <xsl:apply-templates />
        </tbody>
      </table>
    </div>
  </xsl:template>

  <xsl:template match="TypeNameReference">
    <tr>
      <td>
        <code>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@SafeName" />.html
            </xsl:attribute>
            <xsl:value-of select="@FullName" />
          </a>
        </code>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="Type">
    <tr>
      <td>
        <code>
          <xsl:value-of select="@FullName" />
        </code>
      </td>
      <xsl:if test="string-length(@Message) != 0">
        <td>
          <xsl:value-of select="@Message" />
        </td>
      </xsl:if>
    </tr>
  </xsl:template>

  <xsl:template name="navigation">
    <div id="navigation">
      <ul>
        <li>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@SummaryName" />.html
            </xsl:attribute>Summary
          </a>
        </li>
      </ul>
    </div>
  </xsl:template>

</xsl:stylesheet>
